<%--
  Created by IntelliJ IDEA.
  User: xianfei
  Date: 15-9-9
  Time: 下午7:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>周次时间管理</title>
    <script>
        $(function () {
            change();
            $("#selectAll").on("click", function () {
                if ($(this).is(":checked")) {
                    $(":checkbox").prop("checked", "true");
                } else {
                    $(":checkbox").removeAttr("checked");
                }
            });
        })

        function change() {
            var area = $("#houseBaseArea").val();
            $.ajax({
                url: '/house_week_time/find_house_week/' + area,
                type: 'get',
                dataType: 'json',
                success: function (data) {
                    $(".table tbody").empty();
                    $(".table tbody").html(data);
                }, error: function () {
                    alert('error');
                }
            })
        }

        function delHouseWeekTime() {
            var checkboxs = $(":checkbox").not("#selectAll");
            var guids = '';
            for (var i = 0; i < checkboxs.length; i++) {
                if (checkboxs.eq(i).is(":checked")) {
                    guids += i == checkboxs.length - 1 ? checkboxs.eq(i).val() : checkboxs.eq(i).val() + ',';
                }
            }
            console.log(guids);
            $.ajax({
                url: '/house_week_time/del/' + guids,
                type: 'get',
                dataType: 'text',
                success: function (data) {
                    location.reload();
                }, error: function () {
                    alert('error');
                }
            })
        }
    </script>
</head>
<body>
<div>
    <div>
        区域：
        <select id="houseBaseArea" onchange="change()">
            <c:forEach items="${areas}" var="area">
                <option value="${area.name}">${area.label}</option>
            </c:forEach>
        </select>
    </div>
    <button type="button" class="btn btn-info" onclick="delHouseWeekTime()" title="批量删除">批量删除</button>
    <table class="table table-striped" style="height: 45px;">
        <thead>
            <th><label><input type="checkbox" id="selectAll"/>全选</label></th>
            <th>名称</th>
            <th>度假屋</th>
            <th>价格</th>
            <th>开始时间</th>
            <th>结束时间</th>
            <th>月份</th>
        </thead>
        <tbody>
        </tbody>
    </table>
</div>
</body>
</html>